package com.tuo51.core.repositories;

import com.tuo51.evaluate.domain.childrens.Children;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ClassesChildrenRepository extends JpaRepository<Children, String>, JpaSpecificationExecutor<Children> {

    @Query(value = "select * from children c " +
            "LEFT JOIN `rel_classes_children` rcc on rcc.`childrenId` = c.id " +
            "where rcc.`classesId` = :classesId", nativeQuery = true)
    List<Children> findChildrenByClasses(@Param("classesId")  String classesId);

}
